<template>
  <div>
    <h2>门店添加</h2>
    <table>
      <tbody>
        <tr>
          <td>门店名称</td>
          <td><input type="text" v-model="form.name" /></td>
        </tr>
        <tr>
          <td>门店地址</td>
          <td><input type="text" v-model="form.adder" /></td>
        </tr>
        <tr>
          <td>门店电话</td>
          <td><input type="text" v-model="form.phone" /></td>
        </tr>
        <tr>
          <td></td>
          <td><button @click="Add">添加</button></td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { onMounted, reactive, ref } from "vue";
import { useRouter } from "vue-router";

const router = useRouter();

const form = reactive({
  id: 0,
  name: "",
  adder: "",
  phone: "",
});

const Add=()=>{
    if(!form.name){
        alert("不能为空");
        return;
    }
    axios.post("https://localhost:7250/api/mendian",form).then(res=>{
        if(res.data>0){
            alert("添加成功");
            router.push("/showmen");
        }
        else
        {
            alert("添加失败");
        }
    })



}



</script>

<style scoped></style>
